using System;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Domain.Entities;
using UserInterface.Misc;

namespace UserInterface.UserControls
{
    public partial class PreviewMessage : System.Web.UI.UserControl
    {
        private Message message;

        public Message Message
        {
            get { return message; }
            set { message = value; }
        }
        
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (Visible)
            {
                if (message != null)
                {
                    PreviewText.Text = MML.Manager.Process(message.Text, message);
                    PreviewUsername.Text = message.Poster.Username;
                    if (!String.IsNullOrEmpty(message.Poster.AvatarUrl))
                    {
                        PreviewAvatarImage.ImageUrl = message.Poster.AvatarUrl;
                    }
                    PreviewRegisteredDate.Text = OutputTools.FormatDate(message.Poster.RegisterDateTime);
                    PreviewPostDate.Text = OutputTools.FormatDate(message.PostDateTime);
                }
            }
        }
    }
}